package com.tobeface.sns.infrastructure.persist.blog.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;

import com.tobeface.sns.domain.blog.BlogComment;
import com.tobeface.sns.infrastructure.persist.CrudMongoRepositorySupport;
import com.tobeface.sns.infrastructure.persist.blog.BlogCommentRepository;

/**
 * @author Linxiaosheng
 */
@Repository
public class BlogCommentRepositoryImpl extends CrudMongoRepositorySupport<BlogComment, String> implements BlogCommentRepository {

	@Autowired
	protected BlogCommentRepositoryImpl(MongoOperations mongoOperations) {
		super(mongoOperations);
	}

	@Override
	public void create(BlogComment blogComment) {
		super.save(blogComment);
	}

	@Override
	public void delete(String id) {
		super.delete(id);
	}

	@Override
	public List<BlogComment> findCommentByBlogId(String id) {
		return getMongoOperations().find(new Query().addCriteria(new Criteria("blog.id").is(id)), BlogComment.class);
	}

}
